<template>
    <div class="trainPage">
        <div class='block'>
            <div class="Ti">我的计划</div>
            <CourseItem :data='myCourse[0]'/>
        </div>
        <div class="block">
            <div class="title">训练记录</div>
            <div class="ul-item">
                <div class="courseTitle">{{record.title}}</div>
                <div class="nandu">
                    <span>难度</span>
                    <i v-for="item in [1,2,3,4,5]" :key="item" v-if="item <= record.star" class="iconfont icon-wujiaoxing star"></i>
                    <span class="reliang">{{record.reliang}}</span>
                </div>
                <span class="times">{{record.time}}</span>
            </div>
        </div>
        <div class="block">
            <div class="Ti">添加训练</div>
            <div v-for="(item,index) in course" :key="index">
                <courseItem :data='item' />
            </div>
        </div>
        <div class="marginbottom"></div>
    </div>
</template>

<script>
import CourseItem  from '../../components/Course/CourseItem'
export default {
    components:{
        CourseItem
    },
    data() {
        return {
            course:[],
            myCourse:[],
            record:{}
        }
    },
    mounted() {
        this.api.GetCourse().then(res=>{
           
            if(res.data.success){
                this.course= res.data.courseData;
                this.myCourse=res.data.courseData.filter(item=>{
                    return item.isJoin
                })
               
            }
        })

        this.api.GetRecord().then(res=>{
            
            if(res.data.success){
                this.record=res.data.Record[0]
            }
        })
    },
}
</script>

<style lang="less" scoped>
.trainPage{
    width: 100%;
    height: 100%;
    background: #eee;
    box-sizing: border-box;
    .block {
    margin-bottom: 0.2rem;
    background: #fff;
    position: relative;
        .title {
        height: 0.6rem;
        padding: 0.2rem 0;
        text-align: center;
        background: #fff;
        border-bottom: 1px solid #ddd;
        }
        .Ti{
            text-align: center;
            padding: 0.1rem 0;
        }
    }
    .ul-item {
        width: 100%;
        height: 1.5rem;
        line-height: 1.5rem;
        text-align: left;
        padding-left: 0.2rem;
        font-size: 0.4rem;
        box-sizing: border-box;
        border-bottom: 1px solid #ddd;
        position: relative;
        .times{
            position: absolute;
            top: 0rem;
            right: 0.3rem;
        }
        .nandu{
            line-height: 0.6rem;
            color: #999;
            font-size: 0.32rem;
            letter-spacing: 2px;
        }
        .reliang{
            margin-left: 1.2rem;
        }
    }

    .courseTitle{
        height: 0.8rem;
        line-height: 0.8rem;
    }

    .marginbottom{
        height: 1rem;
    }
}
</style>